package com.aidex.system.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.system.domain.VCsisBusinessRecord;
import com.aidex.system.service.VCsisBusinessRecordService;

/**
 * 国内过检数据Controller
 * @author wll
 * @email wll
 * @date 2021-10-14
 */
@RestController
@RequestMapping("/system/vCsisBusinessRecord")
public class VCsisBusinessRecordController extends BaseController
{
    @Autowired
    private VCsisBusinessRecordService vCsisBusinessRecordService;

    /**
     * 查询国内过检数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:list')")
    @GetMapping("/list")
    public R<PageInfo> list(VCsisBusinessRecord vCsisBusinessRecord, HttpServletRequest request, HttpServletResponse response)
    {
        vCsisBusinessRecord.setPage(new PageDomain(request, response));
        return R.data(vCsisBusinessRecordService.findPage(vCsisBusinessRecord));
    }

    /**
     * 获取国内过检数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:query')")
    @GetMapping(value = "/{id}")
    public R<VCsisBusinessRecord> detail(@PathVariable("id") String id)
    {
        return R.data(vCsisBusinessRecordService.get(id));
    }

    /**
     * 新增国内过检数据
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:add')")
    @Log(title = "国内过检数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  VCsisBusinessRecord vCsisBusinessRecord)
    {
        return R.status(vCsisBusinessRecordService.save(vCsisBusinessRecord));
    }

    /**
     * 修改国内过检数据
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:edit')")
    @Log(title = "国内过检数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated VCsisBusinessRecord vCsisBusinessRecord)
    {
        return R.status(vCsisBusinessRecordService.save(vCsisBusinessRecord));
    }


    /**
     * 删除国内过检数据
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:remove')")
    @Log(title = "国内过检数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(vCsisBusinessRecordService.deleteVCsisBusinessRecordByIds(ids));
    }


    /**
     * 导出国内过检数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:vCsisBusinessRecord:export')")
    @Log(title = "国内过检数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(VCsisBusinessRecord vCsisBusinessRecord)
    {
        List<VCsisBusinessRecord> list = vCsisBusinessRecordService.findList(vCsisBusinessRecord);
        ExcelUtil<VCsisBusinessRecord> util = new ExcelUtil<VCsisBusinessRecord>(VCsisBusinessRecord.class);
        return util.exportExcel(list, "vCsisBusinessRecord");
    }

}
